package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.engineering.IView.IFeedBackDetailView;
import com.cloudsigns.factorymanager2.engineering.bean.EngineeringDailyFeedBackBean;
import com.cloudsigns.factorymanager2.engineering.model.FeedBackDetailModel;
import com.cloudsigns.factorymanager2.engineering.model.IFeedBackDetailModel;

/**
 * Created by tony on 2018/6/17.
 */

public class FeedBackDetailPresenter {
    private IFeedBackDetailView view;
    private IFeedBackDetailModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public FeedBackDetailPresenter(IFeedBackDetailView view) {
        this.view = view;
        this.model = new FeedBackDetailModel();
    }

    public void feedBackDetail() {


        model.feedBackDetail(view.getDailyFeedbackId(),view.getOrderId(),view.getType(), new FeedBackDetailModel.OnFeedBackDetailListener() {
            @Override
            public void feedBackDetailsuccessed(final  EngineeringDailyFeedBackBean engineeringDailyFeedBackBean) {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.feedBackDetailSuccessed(engineeringDailyFeedBackBean);
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void feedBackDetailfailed(final String desc) {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.feedBackDetailFailed(desc);
                        view.hideLoading();
                    }
                });
            }


        });
    }
}
